package org.nbict.iot.task.realtime.state;

import org.apache.storm.mongodb.common.QueryFilterCreator;
import org.apache.storm.task.IMetricsContext;
import org.apache.storm.trident.state.State;
import org.apache.storm.trident.state.StateFactory;

import java.util.Map;

/**
 * Created by songseven on 18/6/29.
 */
public class TimelyFactory implements StateFactory {

    private Timely.Options options;
    private Comparer transfer;
    private QueryFilterCreator query;

    public TimelyFactory(Timely.Options options, Comparer transfer, QueryFilterCreator query ) {
        this.options = options;
        this.transfer = transfer;
        this.query = query;
    }

    @Override
    public State makeState(Map conf, IMetricsContext metrics, int partitionIndex, int numPartitions) {
        Timely state = new Timely(options, transfer, query);
        state.prepare();
        return state;
    }
}
